package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jframe;

public class FADD extends Instruction {
	
	public  void readindex(ByteBuffer reader) {
		//no need to read
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
        Object temp2v=stack[top-1];
        Object temp1v=stack[top-2];
        top=top-2;
    	int temp1=(int)temp1v;
    	int temp2=(int)temp2v;
        float value1=Float.intBitsToFloat(temp1);
        float value2=Float.intBitsToFloat(temp2);
    	float value=value1+value2;
    	int temp=Float.floatToIntBits(value);
    	stack[top]=temp;
    	top=top+1;
    	frame.setManagestack(stack);
    	frame.setStacktop(top);
	}
}
